package ch.il07.utils.logging;

public enum Level {
	ERROR(9), WARNING(8), INFO(6), FINE(4);
	
	private int levelID;
	
	Level(int levelID) {
		this.levelID = levelID;
	}
	
	/**
	 * 
	 * @param level
	 * @return true if the submitted level is higher than the current one
	 */
	public boolean isHigher(Level level) {
		return level.levelID >= levelID;
	}
	
	public static Level getLevelByID(int levelID) {
		for(Level current : values()) {
			if(current.levelID == levelID) {
				return current;
			}
		}
		throw new IllegalArgumentException("no Level for ID ["+levelID+"] available");
	}
	
	public static Level getLevelByName(String level) {
		for(Level current : values()){
			if(current.name().equals(level)) {
				return current;
			}
		}
		throw new IllegalArgumentException("no Level for name ["+level+"] available");
	}
	
	public int getLevelID() {
		return levelID;
	}
}
